<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<f:view>	
	<p:tabView id="tab">
		<p:tab title="Dados Pessoais">
			<h:panelGroup id="group_verifica_cpf" rendered="#{!clienteManager.isCpfValido}">
				<h:panelGrid columns="2">
					<h:outputText value="CPF" />
					<h:outputText value="" />
					<p:inputMask id="cpf" mask="999.999.999-99" value="#{clienteManager.cliente.pessoa.cpf}" required="true" label="CPF" converter="cpfConverter" />
					<p:commandButton value="Verificar" id="verificar_cpf" ajax="false" action="#{clienteManager.validateCpf}" />
				</h:panelGrid>
			</h:panelGroup>
		
			<h:panelGroup  rendered="#{clienteManager.isCpfValido}">
				<table>
					<tr>
						<td>
							<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
								<h:outputText value="CPF" />
								<h:outputText value="Nome" />
								<p:inputMask mask="999.999.999-99" id="cpf_read" value="#{clienteManager.cliente.pessoa.cpf}" required="true" label="CPF" converter="cpfConverter" maxlength="14" readonly="true"/>
								<p:inputText value="#{clienteManager.cliente.pessoa.nome}" id="nome" label="Nome" required="true" maxlength="255" style="width:400px;">
									<f:validateLength maximum="255" minimum="2"/>
								</p:inputText>
							</h:panelGrid>
							
							<h:panelGrid columns="3" cellpadding="0" cellspacing="0">
								<h:outputText value="RG" />
								<h:outputText value="Nascimento" />
								<h:outputText value="Sexo" />
								
								
								<p:inputText value="#{clienteManager.cliente.pessoa.rg}" maxlength="255" id="rg" label="RG">
									<f:validateLength maximum="255" minimum="0"/>
								</p:inputText>
								
								<p:calendar value="#{clienteManager.cliente.pessoa.dataNascimento}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
											label="Data de Nascimento" id="nascimento" navigator="true" readOnlyInputText="true"/>
								
								<h:selectOneRadio value="#{clienteManager.cliente.pessoa.sexo}" required="true" label="Sexo" id="sexo">
									<f:selectItem itemValue="M" itemLabel="Masculino" />
									<f:selectItem itemValue="F" itemLabel="Feminino" />
								</h:selectOneRadio>
								
							</h:panelGrid>
						</td>
						<td style="vertical-align: top; width: 50%;">
							<p:commandButton value="Pet's" action="#{animalManager.prepareSave}" 
								oncomplete="pet_dialog.show();" style="text-align: center; height: 80px; width: 150px; float: right;" 
								update=":form_animal"	
							>
							</p:commandButton>
						</td>
					</tr>						
				</table>
			
				<p:panel header="Endereços" >
					<ui:include src="/geral/paginas/geral/formEndereco.xhtml" />
				</p:panel>
				<p:panel header="Telefones">
					<ui:include src="/geral/paginas/geral/formTelefone.xhtml" />
				</p:panel>
			</h:panelGroup>
		</p:tab>
	</p:tabView>
	
	<p:commandButton action="#{clienteManager.save}" value="Salvar" rendered="#{clienteManager.cliente.id == null and clienteManager.isCpfValido}" update="form" />
	<p:commandButton action="#{clienteManager.update}" value="Salvar" rendered="#{clienteManager.cliente.id != null and clienteManager.isCpfValido}" update="form"  />
	
</f:view>
</html>